package com.vehicle.coupon.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vehicle.common.log.annotation.Log;
import com.vehicle.common.log.enums.BusinessType;
import com.vehicle.common.security.annotation.PreAuthorize;
import com.vehicle.coupon.domain.CouponRecordCopy1;
import com.vehicle.coupon.service.ICouponRecordCopy1Service;
import com.vehicle.common.core.web.controller.BaseController;
import com.vehicle.common.core.web.domain.AjaxResult;
import com.vehicle.common.core.utils.poi.ExcelUtil;
import com.vehicle.common.core.web.page.TableDataInfo;

/**
 * 优惠券领取记录Controller
 *
 * @author XU
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/copy1")
public class CouponRecordCopy1Controller extends BaseController
{
    @Autowired
    private ICouponRecordCopy1Service couponRecordCopy1Service;

    /**
     * 查询优惠券领取记录列表
     */
    @PreAuthorize(hasPermi = "coupon:copy1:list")
    @GetMapping("/list")
    public TableDataInfo list(CouponRecordCopy1 couponRecordCopy1)
    {
        startPage();
        List<CouponRecordCopy1> list = couponRecordCopy1Service.selectCouponRecordCopy1List(couponRecordCopy1);
        return getDataTable(list);
    }

    /**
     * 导出优惠券领取记录列表
     */
    @PreAuthorize(hasPermi = "coupon:copy1:export")
    @Log(title = "优惠券领取记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CouponRecordCopy1 couponRecordCopy1) throws IOException
    {
        List<CouponRecordCopy1> list = couponRecordCopy1Service.selectCouponRecordCopy1List(couponRecordCopy1);
        ExcelUtil<CouponRecordCopy1> util = new ExcelUtil<CouponRecordCopy1>(CouponRecordCopy1.class);
        util.exportExcel(response, list, "优惠券领取记录数据");
    }

    /**
     * 获取优惠券领取记录详细信息
     */
    @PreAuthorize(hasPermi = "coupon:copy1:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(couponRecordCopy1Service.selectCouponRecordCopy1ById(id));
    }

    /**
     * 新增优惠券领取记录
     */
    @PreAuthorize(hasPermi = "coupon:copy1:add")
    @Log(title = "优惠券领取记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CouponRecordCopy1 couponRecordCopy1)
    {
        return toAjax(couponRecordCopy1Service.insertCouponRecordCopy1(couponRecordCopy1));
    }

    /**
     * 修改优惠券领取记录
     */
    @PreAuthorize(hasPermi = "coupon:copy1:edit")
    @Log(title = "优惠券领取记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CouponRecordCopy1 couponRecordCopy1)
    {
        return toAjax(couponRecordCopy1Service.updateCouponRecordCopy1(couponRecordCopy1));
    }

    /**
     * 删除优惠券领取记录
     */
    @PreAuthorize(hasPermi = "coupon:copy1:remove")
    @Log(title = "优惠券领取记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(couponRecordCopy1Service.deleteCouponRecordCopy1ByIds(ids));
    }
}
